@layout("/common/_container.html"){
<div class="ibox float-e-margins">
    <div class="ibox-content">
        <div class="form-horizontal" id="itemsInfoForm">

            <div class="row">
                <div class="col-sm-6 b-r">
                    <input id="id" name="账目id" value="${item.id}" underline="true" type="hidden"/>
<!--                            <#input id="id" name="账目id" value="${item.id}" underline="true"/>-->
<!--                            <#input id="accountid" name="账户id" value="${item.accountid}" underline="true"/>-->
<!--                            <#input id="paykind" name="支出类型" value="${item.paykind}" underline="true"/>-->
<!--                            <#input id="createtime" name="创建时间" value="${item.createtime}" />-->


                    <#select id="accountid" name="账户" underline="true" >
                        @for(items in accounts){
                        <option value="${items.id}">${items.accountname}</option>
                        @}
                    </#select>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">收/支</label>
                        <div class="col-sm-9">
                            <select class="form-control" id="shouZhi" name="收/支" onchange="changeShouZhi()">
                                <option value="zclx">支出</option>
                                <option value="srlx">收入</option>
                            </select>

                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>

                    <#select id="paykind" name="收支类型" underline="true" >

                    </#select>


                    <#input id="paytime" name="收支时间" value="${item.paytime}" underline="true"/>


                </div>

                <div class="col-sm-6">
<!--                            <#input id="updatetime" name="更新时间" value="${item.updatetime}" underline="true"/>-->
<!--                            <#input id="updateid" name="更新人" value="${item.updateid}" underline="true"/>-->
                            <input id="spare1" name="空闲字段1" value="${item.spare1}" type="hidden" underline="true"/>
                            <input id="spare2" name="空闲字段2" value="${item.spare2}" type="hidden" underline="true"/>
                            <input id="spare3" name="空闲字段3" value="${item.spare3}" type="hidden"/>

                    <#input id="remark" name="备注" value="${item.remark}" underline="true"/>
                    <#input id="pay" name="收支金额" value="${item.pay}" underline="true"/>
                    <#input id="payplace" name="收支地点" value="${item.payplace}" underline="true"/>

                </div>
            </div>

            <div class="row btn-group-m-t">
                <div class="col-sm-10">
                    <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="ItemsInfoDlg.editSubmit()"/>
                    <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="ItemsInfoDlg.close()"/>
                </div>
            </div>
        </div>

    </div>
</div>
<script src="${ctxPath}/static/modular/items/items/items_info.js"></script>
<script language="JavaScript">

    var classzhichu=[];
    var namezhichu=[];
    var classshouru=[];
    var nameshouru=[];

    function ajax1() {
        $.ajax({
            type: "post", // 以get方式发起请求
            url: Feng.ctxPath + "/items/getMessage", // 将你的请求参数以问号拼接到url中进行参数传递
            success(data) {
                for(var d in data){
                    if(data[d]['v1']=="zclx"){
                        classzhichu.push(data[d]['v2']);
                        namezhichu.push(data[d]['v3']);

                    }
                    else if(data[d]['v1']=="srlx"){
                        classshouru.push(data[d]['v2']);
                        nameshouru.push(data[d]['v3']);
                    }

                }



                /////////
                for(var i=0;i<classshouru.length;i++){
                    // alert("classshouru[i] "+classshouru[i]);
                    if(classshouru[i]=='${item.paykind}'){
                        $("#shouZhi").find("option[value='srlx']").attr("selected",true);
                        break;
                    }
                }
                for(var i=0;i<classzhichu.length;i++){
                    if(classzhichu[i]=='${item.paykind}'){
                        $("#shouZhi").find("option[value='zclx']").attr("selected",true);
                        break;
                    }
                }
                changeShouZhi();
                $("#paykind").find("option[value='${item.paykind}']").attr("selected",true);

            },
            error(data){
                alert("cuowu");
            }

        })
    }

    function changeShouZhi() {

        var value =$('#shouZhi').val();
        var shouru=document.getElementById("shouZhi");
        var paykind=document.getElementById("paykind");
        paykind.options.length = 0;
        if(value=="zclx"){
            for(var i=0;i<classzhichu.length;i++){
                option = new Option(namezhichu[i],classzhichu[i] );
                paykind.options.add(option);
            }
        }
        else if(value=="srlx"){
            for(var i=0;i<classshouru.length;i++){
                option = new Option(nameshouru[i],classshouru[i]);
                paykind.options.add(option);
            }
        }


    }

    ajax1();

    laydate.render({
        elem:'#paytime',trigger:'click',type:'datetime'
    });
    $("#accountid").find("option[value='${item.accountid}']").attr("selected",true);
    $("#paytime").val("${item.paytime,dateFormat='yyyy-MM-dd HH:mm:ss'}");





</script>

@}
